/* --------------------------------------------------------
 * Copyright (c) aeky , Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.client.ui;

import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.Progressbar;
import com.smartgwt.client.widgets.Window;

/**
 * 
 * @author aeky
 */
public class AekyProgressBar extends Window {

    private Progressbar progressBar = new Progressbar();

    private int i = 0;

    public AekyProgressBar() {
        this.initAekyProgressBar();
        progressBar.setTitle("正在处理您的请求，请稍后...");
        this.addItem(progressBar);
        this.doSchedule();
    }

    public void initAekyProgressBar() {
        progressBar.setShowTitle(Boolean.TRUE);
        this.setShowEdges(Boolean.FALSE);
        this.setIsModal(Boolean.TRUE);
        this.setShowHeader(Boolean.FALSE);
        this.setWidth(250);
        this.setHeight(30);
        this.centerInPage();
    }

    private void doSchedule() {
        new Timer() {
            public void run() {
                i += 10;
                if (i > 100) {
                    i = 10;
                }
                progressBar.setPercentDone(i);
                schedule(200);
            }
        }.schedule(200);
    }

}
